<?php

class m111221_041412_create_testimony extends CDbMigration {

	protected $_tables = array(
		'testimony'=>array(
			'fields'=>array(
				'_id'=>'pk',
				'insertTime'=>'integer',
				'updateTime'=>'integer',
				'name'=>'string',
				'address'=>'string',
				'extension'=>'string',
				'value'=>'text',
			),
			'indexes'=>array(
				'_id',
				'insertTime',
				'updateTime',
			),
		),
	);

	public function safeUp() {
		foreach ($this->_tables as $table=>$types) {
			$this->createTable($table, $types['fields']);
			foreach ($types['indexes'] as $index) {
				$this->createIndex("idx_{$table}_{$index}", $table, $index);
			}
		}
	}

	public function safeDown() {
		foreach ($this->_tables as $table=>$types) {
			foreach ($types['indexes'] as $index) {
				$this->dropIndex("idx_{$table}_{$index}", $table, $index);
			}
			$this->dropTable($table, $types['fields']);
		}
	}

}